<?php
class ComponentFactory {
	
	public static function getComponent($path, $categoryClass) {
		if(isset($path) and isset($categoryClass)) {
			include_once $path;
			$com = new $categoryClass;
			if(isset($com)) {
				return $com;
			} else {
				throw new Exception ('Component not found');
			}
		} else {
			throw new Exception ('path or categoryClass not found');
		}
	}
}

abstract class Component {
	
	private $dao;
	
	function getDao(){
		if(!isset($this->dao)){
			$this->dao = new Dao();
		}
		return $this->dao;
	}
	
	abstract function getHomeRecords($pageSize = 10);
	
	/**
	 * 获取当前组件的记录数记录
	 * Enter description here ...
	 * @param $pageSize
	 * @param $pageIndex
	 * //@param $pageLevel 0表示普通页面， 1表示会员页面， 2表示管理员页面
	 */
	abstract function getRecords($pageIndex = 1, $pageSize = 20);
	
	abstract function getRecord($id);
}

?>